package ${package}.modules.${functionName}.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yf.exam.core.api.dto.PagingReqDTO;
import com.yf.exam.core.enums.OpenType;
import com.yf.exam.core.exception.ServiceException;
import com.yf.exam.core.utils.BeanMapper;
import ${package}.modules.${functionName}.dto.${ClassName}DTO;
import ${package}.modules.${functionName}.dto.request.${ClassName}SaveReqDTO;

import ${package}.modules.${functionName}.entity.${ClassName};
import ${package}.modules.${functionName}.mapper.${ClassName}Mapper;

import ${package}.modules.${functionName}.service.${ClassName}Service;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * ${tableComment}业务实现类
 *
 * @author ${author} ${email}
 * @since ${version} ${date}
 */
@Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements ${ClassName}Service {







            @Override
            public void save(${ClassName}SaveReqDTO reqDTO) {

            // ID
            String id = reqDTO.getId();

            if(StringUtils.isBlank(id)){
            id = IdWorker.getIdStr();
            }

            //复制参数
            ${ClassName} entity = new ${ClassName}();



            // 复制基本数据
            BeanMapper.copy(reqDTO, entity);
            entity.setId(id);



            this.saveOrUpdate(entity);

            }
        @Override
        public ${ClassName}DTO findById(String id) {
            ${ClassName}DTO respDTO = new ${ClassName}DTO();
            ${ClassName} entity = this.getById(id);
            BeanMapper.copy(entity, respDTO);
            return respDTO;
        }

        @Override
        public IPage<${ClassName}DTO> paging(PagingReqDTO<${ClassName}DTO> reqDTO) {

            //创建分页对象
            Page page = new Page(reqDTO.getCurrent(), reqDTO.getSize());

            //转换结果
            IPage<${ClassName}DTO> pageData = baseMapper.paging(page, reqDTO.getParams());
            return pageData;

         }

        @Transactional(rollbackFor = Exception.class)
        @Override
        public void delete(List<String> ids) {
        this.removeByIds(ids);
      }
     }